package com.example.uitest;

import java.io.IOException;
import java.util.ArrayList;
import java.util.zip.Inflater;

import Send.Like_Unlike;
import android.content.Context;
import android.graphics.Typeface;
import android.renderscript.Type;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextSwitcher;
import android.widget.TextView;
import android.widget.ViewSwitcher.ViewFactory;

public class ListViewAdapter1 extends BaseAdapter implements OnClickListener, ViewFactory{//
	//public static String rosa = "ROSA";
	private LayoutInflater inflater = null;
	private ViewHolder holder = null;
	private Context mContext = null;
	private ArrayList<ListData> mListData = null;
	
	public AsyncTask_01 A;
	
	public ListViewAdapter1(Context c , ArrayList<ListData> arrays){
		this.mContext = c;
		this.inflater = LayoutInflater.from(c);
		this.mListData = arrays;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mListData.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mListData.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		View v = convertView;
		
		ListData a = new ListData(mListData.get(position).tv_sns);
		
	    if (convertView == null) {
	        holder = new ViewHolder();
	 
	        inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	        v = inflater.inflate(R.layout.sns_based, null);
	 
	       
	        holder.tv_sns = (TextView) v.findViewById(R.id.based_tv_sns);
	        holder.tv_sns.setText(a.tv_sns);
	        holder.tv_sns.setTypeface(BaseActivty.mTypeface);
	
	        v.setTag(holder);
	        
	        
	    }else{
	        holder = (ViewHolder) v.getTag();
	        holder.tv_sns.setText(a.tv_sns);
	    }
	 
	    ListData mData = mListData.get(position);
	 
	    //holder.sns.setText(getItem(position).);    
        
	    return v;
	}	
	
	class ViewHolder{
		public TextView tv_sns = null;
	}

	@Override
	public void onClick(View v) {
	
	}	

	@Override
	public View makeView() {
		// TODO Auto-generated method stub
		TextView t = new TextView(mContext);
	    t.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
	    t.setTextSize(15);
        return t;
	}	
}	